package com.qianfeng.zhangwei.xutils.ui;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.lidroid.xutils.view.annotation.event.OnClick;
import com.qianfeng.zhangwei.xutils.R;
import com.qianfeng.zhangwei.xutils.annotation.ResInit;
import com.qianfeng.zhangwei.xutils.annotation.ViewInit;
import com.qianfeng.zhangwei.xutils.bean.ResType;
import com.qianfeng.zhangwei.xutils.utils.VIewUtil;

/**
 * 第一步使用注解的方式声明在初始化的控件上面
 * 第二步
 */

public class MainActivity extends AppCompatActivity {
    @ViewInit(id = R.id.text)
    private TextView text;
    @ViewInit(id = R.id.btn)
    private Button btn;
    @ViewInit(id = R.id.imageview)
    private ImageView img;
    @ResInit(id = R.string.app_name, type = ResType.String)
    private String appName;
//    @ResInject(id = R.mipmap.ic_launcher, type = ResType.Drawable)
//    private Drawable drawable;
//
//    private BaseAdapter adapter;
//
//    private List<String> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        VIewUtil.ViewInit(this);
        text.setText("花开花落");
        btn.setText("呵呵");
        img.setImageResource(R.mipmap.ic_launcher);
        this.findViewById(R.id.action0);

        getResources().getString(R.string.app_name);
        getResources().getDrawable(R.mipmap.ic_launcher);


    }

    @OnClick({R.id.btn, R.id.imageview})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn:
                Toast.makeText(this, "Hello World", Toast.LENGTH_SHORT).show();
                break;
            case R.id.imageview:
                Toast.makeText(this, "img", Toast.LENGTH_SHORT).show();
                break;
        }

    }


}
